package eu.webhib.webblog.domain;

import eu.webhib.webblog.domain.base.CommonParentChildEntityImpl;
import java.util.*;
import javax.persistence.*;
import org.apache.log4j.Logger;


//
@javax.persistence.Entity
@javax.persistence.NamedQueries({
   @javax.persistence.NamedQuery(name = "Category_All", query = "SELECT c FROM Category c"),
   @javax.persistence.NamedQuery(name = "Category_AllOrdered", query = "SELECT c FROM Category c order by title")
})
@Access(AccessType.FIELD)
public class Category extends CommonParentChildEntityImpl<Category> {
   //
   private static final Logger log = Logger.getLogger(Category.class);
   private static final long serialVersionUID = 1L;
   // attributes
   @Column(nullable = false)
   private String title;
   @Column(nullable = false)
   private String description;
   // relations
   @ManyToOne(optional = true, fetch = FetchType.LAZY)
   private Category parent;
   @OneToMany(mappedBy = "category")
   private List<Posting> postings = new ArrayList<Posting>();

   //
   // getter/setter
   //
   @Override
   public String getLabel() {
      return title;
   }

   public String getTitle() {
      return title;
   }

   public void setTitle(String title) {
      this.title = title;
   }

   public String getDescription() {
      return description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   @Override
   public Category getParent() {
      return parent;
   }

   @Override
   public void setParent(Category parent) {
      this.parent = parent;
   }

   public List<Posting> getPostings() {
      return postings;
   }
}
